import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import viteEslint from 'vite-plugin-eslint'
import viteStylelint from '@amatlash/vite-plugin-stylelint'
// eslint-disable-next-line import/no-unresolved
import Components from 'unplugin-vue-components/vite'
// 注意，这种方法并不会处理函数 API，比如 useMessage，用户仍需要手动导入对应 API，例如 import { useMessage } from 'naive-ui'。
// eslint-disable-next-line import/no-unresolved
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  plugins: [
    vue(),
    viteEslint(), // 用于vite项目的eslint插件
    Components({
      resolvers: [NaiveUiResolver()],
    }),
    viteStylelint({
      // 对某些文件排除检查
      exclude: /windicss|node_modules/,
    }),
  ],
  resolve: {
    extensions: ['.ts', '.tsx'], // vite开启省略导入后缀名
    alias: [
      {
        find: '@',
        replacement: path.resolve(__dirname, 'src'),
      },
    ],
  },
})
